﻿#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef double Real;

typedef struct {
	int a;
	int b;
}Rational;

typedef struct {
	int m;
	int n;
	int data[20][20];
}Matrix;
 
typedef struct 
{
	int n;
	Rational a;
	Rational b;
	char s1[255];
	char s2[80];
}Context;

Context context;

Rational read_rational()
{
	Rational r;
	scanf("%d/%d", &r.b, &r.a);
	return r;
}

int gcd(int a, int b)
{
	if (a < b)
	{
		int c = a;
		a = b;
		b = c;
	}
	while (a % b) {
		int c = a % b;
		a = b;
		b = c;
	}
	return b;
}

Rational add(Rational* r1, Rational* r2)
{
	Rational r;
	int a0 = gcd(r1->a, r2->a);
	r.b = r1->b * (r2->a/a0) + r2->b * (r1->a/a0);
	r.a = r1->a / a0 * r2->a;
	a0 = gcd(r.a, r.b);
	r.a /= a0;
	r.b /= a0;
	return r;
}

void dump_rational(Rational* r)
{
	printf("%d", r->b);
	if (r->a != 1)
		printf("/%d", r->a);
	printf("\n");
}

Matrix* read_mat(Matrix* A)
{
	scanf("%d %d", &A->m, &A->n);
	for (int i = 0; i < A->m; ++i)
		for (int j = 0; j < A->n; ++j)
			scanf("%d", &A->data[i][j]);
	return A;
}

void get_line(char* s)
{
	char c;
	while (scanf("%c", &c))
	{
		if (c == '\r')
			;
		else if (c == '\n')
			break;
		else
			*s++ = c;
	}
	*s = 0;
}

void read_data(Context* ctx)
{
	ctx->a = read_rational();
	ctx->b = read_rational();

}

void do_task(Context* ctx)
{
	Rational c = add(&ctx->a, &ctx->b);
	dump_rational(&c);
}

void solve(Context* ctx)
{
	read_data(ctx);
	do_task(ctx);
}

int main()
{
	freopen("D:/Develop/GitRepos/MOOC/浙江大学/数据结构/201906/DataStructure/M2019秋C入门和进阶练习集/7-160.txt", "r", stdin);
	solve(&context);
	return 0;
}
